(()=>{var os=(V,O)=>()=>(O||V((O={exports:{}}).exports,O),O.exports);var as=os((W,Mt)=>{(function(O,S){typeof W=="object"&&typeof Mt=="object"?Mt.exports=S():typeof define=="function"&&define.amd?define([],S):typeof W=="object"?W.KoalaSDK=S():O.KoalaSDK=S()})(self,()=>(()=>{var V={639:()=>{(function(p){if(typeof p.requestSubmit=="function")return;p.requestSubmit=function(v){v?(T(v,this),v.click()):(v=document.createElement("input"),v.type="submit",v.hidden=!0,this.appendChild(v),v.click(),this.removeChild(v))};function T(v,D){v instanceof HTMLElement||y(TypeError,"parameter 1 is not of type 'HTMLElement'"),v.type=="submit"||y(TypeError,"The specified element is not a submit button"),v.form==D||y(DOMException,"The specified element is not owned by this form element","NotFoundError")}function y(v,D,mt){throw new v("Failed to execute 'requestSubmit' on 'HTMLFormElement': "+D+".",mt)}})(HTMLFormElement.prototype)}},O={};function S(p){var T=O[p];if(T!==void 0)return T.exports;var y=O[p]={exports:{}};return V[p](y,y.exports,S),y.exports}S.d=(p,T)=>{for(var y in T)S.o(T,y)&&!S.o(p,y)&&Object.defineProperty(p,y,{enumerable:!0,get:T[y]})},S.o=(p,T)=>Object.prototype.hasOwnProperty.call(p,T),S.r=p=>{typeof Symbol!="undefined"&&Symbol.toStringTag&&Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(p,"__esModule",{value:!0})};var ht={};return(()=>{"use strict";S.r(ht),S.d(ht,{getNamespace:()=>Pe,load:()=>xe,mountWidget:()=>Ie});function p(e,t,i,n,r){var s,o=r&&r+i;if(n==null)t&&(e[r]=n);else if(typeof n!="object")e[r]=n;else if(Array.isArray(n))for(s=0;se.length)&&(t=e.length);for(var i=0,n=new Array(t);i=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var gt=32,De=function(){function e(i,n){this.size=void 0,this.field=void 0,this.size=i,this.field=n,this.size=i,this.field=n||[];var r=Math.floor((i-1)/gt+1);if(!n)for(var s=0,o=r-1,a=0<=o;a?s<=o:s>=o;a?s++:s--)this.field[s]=0}var t=e.prototype;return t.add=function(n){return this.set(n,1)},t.remove=function(n){return this.set(n,0)},t.set=function(n,r){if(n>=this.size)throw new Error("BitArray index out of bounds");var s=Nt(n),o=Bt(n);return r===1?this.field[s]=G(this.field[s]|o):(this.field[s]&o)!==0&&(this.field[s]=G(this.field[s]^o)),!0},t.get=function(n){if(n>=this.size)throw new Error("BitArray index out of bounds");var r=Nt(n),s=Bt(n);return G(this.field[r]&s)>0?1:0},e}();function Nt(e){return Math.floor(e/gt)}function Bt(e){return G(1<>>1:e>>>1;t[i]=e}return t}var Me=qe(),Ut=function(t){var i=Ne(t),n=0,r=0;n=n^-1;for(var s=0,o=i.length;s>>8^Me[r],s++;return n=n^-1,n<0&&(n+=4294967296),n},Ne=function(t){for(var i=[],n=0;n=o;a?s++:s--)r.push(Ut(n+":"+(s+this.options.seed))%this.options.size);return r},e}(),Ue=Number.MAX_SAFE_INTEGER-1;function $e(e,t){for(var i=new Array(e),n=0;ne.replace(/\.(\d+)/g,".[]");function Je(e){return typeof e!="object"?!1:!!(e!=null&&e.hasOwnProperty("event"))}function Qe(e){return typeof e!="object"?!1:!!(e!=null&&e.hasOwnProperty("page")&&e.page.path)}function $t(e,t,i){i===void 0&&(i=1),e.counts.add(t.toLowerCase(),i)}function zt(e,t,i){e.counts.setCount(t.toLowerCase(),i)}function Ht(e,t){e.bloom.add(t.toLowerCase())}function Kt(e,t,i){const n=Ge(t);return typeof i=="number"?(zt(e,n+":"+i,i),zt(e,n,i)):(Ht(e,n+":"+i),Ht(e,n)),e}function I(e,t){if(Array.isArray(t)){t.forEach(n=>{I(e,n)});return}if(Je(t)){var i;$t(e,"events."+t.event),Object.entries(T((i=t.properties)!=null?i:{})).forEach(r=>{let[s,o]=r;Kt(e,s,o)});return}if(Qe(t)){$t(e,"page_views."+t.page.path);return}if(typeof t=="object"){Object.entries(T(t)).forEach(r=>{let[s,o]=r;Kt(e,s,o)});return}}function Xe(e){var t,i,n;const r=new CountMinSketch,s=new JsBloom({size:1e4}),o={counts:r,bloom:s};return(t=e.events)==null||t.forEach(a=>{I(o,a)}),(i=e.pageViews)==null||i.map(a=>{I(o,a)}),I(o,(n=e.traits)!=null?n:{}),I(o,{account_score:e.accountScore}),I(o,{company:e.firmographics}),I(o,{person:e.person}),o}function A(e,t){return{is:i=>e.is(t,i),exists:()=>e.has(t),includesItem:function(){for(var i=arguments.length,n=new Array(i),r=0;r!e.is(t,i),includesItem:function(){for(var i=arguments.length,n=new Array(i),r=0;re.has(t),is:i=>e.is(t,i),greaterThan:i=>e.greaterThan(t,i),greaterThanOrEqual:i=>e.greaterThanOrEqual(t,i),lessThan:i=>e.lessThan(t,i),lessThanOrEqual:i=>e.lessThanOrEqual(t,i),not:{is:i=>!e.is(t,i),greaterThan:i=>!e.greaterThan(t,i),greaterThanOrEqual:i=>!e.greaterThanOrEqual(t,i),lessThan:i=>!e.lessThan(t,i),lessThanOrEqual:i=>!e.lessThanOrEqual(t,i)}}}function Wt(e,t){const i=t.toLowerCase();return!!(e.bloom.test(i)||e.counts.count(i))}function Ye(e,t,i){return e.counts.count(t.toLowerCase())>i}function ti(e,t,i){return e.counts.count(t.toLowerCase())>=i}function ei(e,t,i){return e.counts.count(t.toLowerCase())J(e,t+"."+s,i[s]))}function pt(e,t,i){return J(e,t,i)||J(e,t+".[]",i)}function ni(e,t,i){return i.some(n=>pt(e,t,n))}function ri(e,t,i){return i.every(n=>pt(e,t,n))}class Q{constructor(t){this.profile=void 0,this.profile=t,this.profile=t}has(t){return Wt(this.profile,t)}greaterThan(t,i){return Ye(this.profile,t,i)}greaterThanOrEqual(t,i){return ti(this.profile,t,i)}lessThan(t,i){return ei(this.profile,t,i)}lessThanOrEqual(t,i){return ii(this.profile,t,i)}is(t,i){return J(this.profile,t,i)}matchesObject(t,i){return Vt(this.profile,t,i)}includes(t,i){return pt(this.profile,t,i)}includesAnyOf(t,i){return ni(this.profile,t,i)}includesAllOf(t,i){return ri(this.profile,t,i)}get not(){return{has:t=>!this.has(t),greaterThan:(t,i)=>!this.greaterThan(t,i),greaterThanOrEqual:(t,i)=>!this.greaterThanOrEqual(t,i),lessThan:(t,i)=>!this.lessThan(t,i),lessThanOrEqual:(t,i)=>!this.lessThanOrEqual(t,i),is:(t,i)=>!this.is(t,i),matchesObject:(t,i)=>!this.matchesObject(t,i),includes:(t,i)=>!this.includes(t,i),includesAnyOf:(t,i)=>!this.includesAnyOf(t,i),includesAllOf:(t,i)=>!this.includesAllOf(t,i)}}}function _(e,t){return{exists:()=>e.has(t),is:i=>e.is(t,i),includesItem:function(){for(var i=arguments.length,n=new Array(i),r=0;re.includes(t,i),includesAnyOf:function(){for(var i=arguments.length,n=new Array(i),r=0;re.has(t),is:i=>e.is(t,i),greaterThan:i=>e.greaterThan(t,i),greaterThanOrEqual:i=>e.greaterThanOrEqual(t,i),lessThan:i=>e.lessThan(t,i),lessThanOrEqual:i=>e.lessThanOrEqual(t,i)}}class si{constructor(t){this.traits=void 0,this.traits=new Q(t)}get name(){return _(this.traits,"company.name")}get domain(){return _(this.traits,"company.domain")}get sector(){return _(this.traits,"company.category.sector")}get type(){return _(this.traits,"company.type")}get industryGroup(){return _(this.traits,"company.category.industryGroup")}get industry(){return _(this.traits,"company.category.industry")}get subIndustry(){return _(this.traits,"company.category.subIndustry")}get foundedYear(){return M(this.traits,"company.foundedYear")}get timezone(){return _(this.traits,"company.timezone")}get city(){return _(this.traits,"company.geo.city")}get state(){return _(this.traits,"company.geo.state")}get stateCode(){return _(this.traits,"company.geo.stateCode")}get country(){return _(this.traits,"company.geo.country")}get countryCode(){return _(this.traits,"company.geo.countryCode")}get employeeCount(){return M(this.traits,"company.metrics.employees")}get employeesRange(){return _(this.traits,"company.metrics.employeesRange")}get marketCap(){return M(this.traits,"company.metrics.marketCap")}get amountRaised(){return M(this.traits,"company.metrics.raised")}get annualRevenue(){return M(this.traits,"company.metrics.annualRevenue")}get estimatedAnnualRevenue(){return _(this.traits,"company.metrics.estimatedAnnualRevenue")}get tech(){return wt(this.traits,"company.tech")}get techCategories(){return wt(this.traits,"company.techCategories")}get tags(){return wt(this.traits,"company.tags")}isB2B(){return this.tags.includesItem("B2B")}isB2C(){return this.tags.includesItem("B2C")}isEnterprise(){return this.tags.includesItem("Enterprise")}isEcommerce(){return this.tags.includesItem("E-commerce")}isSaas(){return this.tags.includesItem("SAAS")}}function Gt(e,t,i){return i===void 0&&(i=1),Jt(e,i,t)}function oi(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),n=1;nGt(e,r))}function Jt(e,t,i){return e.counts.count(("events."+i).toLowerCase())>=t}class ai{constructor(t){this.profile=void 0,this.profile=t}performed(t,i){return i===void 0&&(i=1),Gt(this.profile,t,i)}performedAnyOf(){for(var t=arguments.length,i=new Array(t),n=0;n!this.performedAtLeast(i,n)}}}function ci(){for(var e=arguments.length,t=new Array(e),i=0;i{if(await e()){t==null||t(),n();return}const s=()=>setTimeout(async()=>{await e()?(t==null||t(),n()):s()},i);s()})}function Qt(e,t,i){return i===void 0&&(i=1),e.counts.count(("page_views."+t).toLowerCase())>=i}const li=Qt;function di(e,t){return window.location.pathname.toLowerCase()===t.toLowerCase()}class fi{constructor(t){this.profile=void 0,this.profile=t,this.profile=t}seen(t,i){return i===void 0&&(i=1),Qt(this.profile,t,i)}viewed(t){return li(this.profile,t)}viewing(t){return di(this.profile,t)}get not(){var t=this;return{seen:function(i,n){return n===void 0&&(n=1),!t.seen(i,n)},viewed:i=>!this.viewed(i),viewing:i=>!this.viewing(i)}}}class hi{constructor(t){this.traits=void 0,this.traits=new Q(t)}get emailType(){return A(this.traits,"person.email_type")}get identifiedWorkEmail(){return this.emailType.is("work")}get identifiedPersonalEmail(){return this.emailType.is("personal")}get identifiedAcademicEmail(){return this.emailType.is("academic")}get isIdentified(){return this.traits.has("person.email_type")}get timezone(){return A(this.traits,"person.timezone")}get city(){return A(this.traits,"person.geo.city")}get state(){return A(this.traits,"person.geo.state")}get stateCode(){return A(this.traits,"person.geo.stateCode")}get country(){return A(this.traits,"person.geo.country")}get countryCode(){return A(this.traits,"person.geo.countryCode")}get company(){return A(this.traits,"person.employment.name")}get title(){return A(this.traits,"person.employment.title")}get role(){return A(this.traits,"person.employment.role")}get subRole(){return A(this.traits,"person.employment.subRole")}get seniority(){return A(this.traits,"person.employment.seniority")}}class mi{constructor(t,i){this.traits=void 0,this.prefix="",this.traits=new Q(t),this.prefix=i}get fitGrade(){return Ze(this.traits,this.prefix+".fit_grade")}get fitGradeLetter(){return A(this.traits,this.prefix+".fit_grade_letter")}}function gi(e,t){I(e,t)}function vt(e){const t=new Be(e.b),n={counts:new Ve(e.c),bloom:t};return{traits:new Q(n),events:new ai(n),page:new fi(n),company:new si(n),person:new hi(n),scores:{account:new mi(n,"account_score")},inSegment:ci,when:ui,raw:n,index:r=>gi(n,r)}}function cs(e){return Xe(e)}const Xt="https://api.getkoala.com";function Zt(e="host"){return typeof globalThis!="undefined"&&globalThis.koalaSettings&&(globalThis.koalaSettings[e]||globalThis.koalaSettings.host)||Xt}const yt=Zt("host"),pi=Zt("wssHost");function Yt(e,t){return fetch(`${yt}${e}`,{method:"POST",body:typeof t=="string"?t:JSON.stringify(t),keepalive:!0,headers:{"Content-Type":"application/json"}})}function wi(e){return fetch(`${yt}${e}`).then(t=>{if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);return t.json()})}const te=navigator.sendBeacon&&navigator.sendBeacon.bind(navigator);function vi(e,t){if(te)try{return te(`${yt}${e}`,t)}catch{}return!1}function N(e,t){const i=JSON.stringify(t);return vi(e,i)||Yt(e,i).then(()=>!0).catch(()=>!1)}async function yi(e,t){return Yt(e,t).then(i=>{if(!i.ok)throw new Error(`${i.status} ${i.statusText}`);const n=i.headers.get("content-type");return n!=null&&n.includes("application/json")?i.json():i.text()})}async function bi(e,t){if(!t.user.id)throw new Error("missing profile id");const i=await yi(`/web/projects/${e}/profiles`,{profile_id:t.user.id,email:t.email,traits:t.traits});return{...i,qualification:i.q}}function _i(e,t,i){return N(`/web/projects/${e}/batch`,{profile_id:t.user.id,email:t.email,traits:t.traits,identifies:[i]})}function Si(e,t,i=[]){if(i.length!==0)return N(`/web/projects/${e}/batch`,{profile_id:t,events:i})}function Ti(e,t,i=[]){if(i.length!==0)return N(`/web/projects/${e}/batch`,{profile_id:t,page_views:i})}function Ai({project:e,...t}){return N(`/web/projects/${e}/utk`,t)}var X={logger:self.console,WebSocket:self.WebSocket},m={log(...e){this.enabled&&(e.push(Date.now()),X.logger.log("[ActionCable]",...e))}};const B=()=>new Date().getTime(),Z=e=>(B()-e)/1e3;class U{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=B(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),m.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=B(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),m.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordPing(){this.pingedAt=B()}recordConnect(){this.reconnectAttempts=0,this.recordPing(),delete this.disconnectedAt,m.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=B(),m.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout(()=>{this.reconnectIfStale(),this.poll()},this.getPollInterval())}getPollInterval(){const{staleThreshold:t,reconnectionBackoffRate:i}=this.constructor,n=Math.pow(1+i,Math.min(this.reconnectAttempts,10)),s=(this.reconnectAttempts===0?1:i)*Math.random();return t*1e3*n*(1+s)}reconnectIfStale(){this.connectionIsStale()&&(m.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${Z(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?m.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${Z(this.disconnectedAt)} s`):(m.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return Z(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&Z(this.disconnectedAt){(this.connectionIsStale()||!this.connection.isOpen())&&(m.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())},200)}}U.staleThreshold=6,U.reconnectionBackoffRate=.15;var ee={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},disconnect_reasons:{unauthorized:"unauthorized",invalid_request:"invalid_request",server_restart:"server_restart"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]};const{message_types:$,protocols:Y}=ee,Ei=Y.slice(0,Y.length-1),ie=[].indexOf;class bt{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new U(this),this.disconnected=!0}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){return this.isActive()?(m.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1):(m.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${Y}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new X.WebSocket(this.consumer.url,Y),this.installEventHandlers(),this.monitor.start(),!0)}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(m.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){m.log("Failed to reopen WebSocket",t)}finally{m.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}isProtocolSupported(){return ie.call(Ei,this.getProtocol())>=0}isState(...t){return ie.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in X.WebSocket)if(X.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){const i=this.events[t].bind(this);this.webSocket[`on${t}`]=i}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){}}}bt.reopenDelay=500,bt.prototype.events={message(e){if(!this.isProtocolSupported())return;const{identifier:t,message:i,reason:n,reconnect:r,type:s}=JSON.parse(e.data);switch(s){case $.welcome:return this.monitor.recordConnect(),this.subscriptions.reload();case $.disconnect:return m.log(`Disconnecting. Reason: ${n}`),this.close({allowReconnect:r});case $.ping:return this.monitor.recordPing();case $.confirmation:return this.subscriptions.confirmSubscription(t),this.subscriptions.notify(t,"connected");case $.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",i)}},open(){if(m.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return m.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(e){if(m.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){m.log("WebSocket onerror event")}};const Ci=function(e,t){if(t!=null)for(let i in t){const n=t[i];e[i]=n}return e};class ki{constructor(t,i={},n){this.consumer=t,this.identifier=JSON.stringify(i),Ci(this,n)}perform(t,i={}){return i.action=t,this.send(i)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}class Oi{constructor(t){this.subscriptions=t,this.pendingSubscriptions=[]}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(m.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):m.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing()}forget(t){m.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter(i=>i!==t)}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout(()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map(t=>{m.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t)})},500)}}class ji{constructor(t){this.consumer=t,this.guarantor=new Oi(this),this.subscriptions=[]}create(t,i){const n=t,r=typeof n=="object"?n:{channel:n},s=new ki(this.consumer,r,i);return this.add(s)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map(i=>(this.forget(i),this.notify(i,"rejected"),i))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter(i=>i!==t),t}findAll(t){return this.subscriptions.filter(i=>i.identifier===t)}reload(){return this.subscriptions.map(t=>this.subscribe(t))}notifyAll(t,...i){return this.subscriptions.map(n=>this.notify(n,t,...i))}notify(t,i,...n){let r;return typeof t=="string"?r=this.findAll(t):r=[t],r.map(s=>typeof s[i]=="function"?s[i](...n):void 0)}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t)}confirmSubscription(t){m.log(`Subscription confirmed ${t}`),this.findAll(t).map(i=>this.guarantor.forget(i))}sendCommand(t,i){const{identifier:n}=t;return this.consumer.send({command:i,identifier:n})}}class Li{constructor(t){this._url=t,this.subscriptions=new ji(this),this.connection=new bt(this)}get url(){return Ii(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}}function Ii(e){if(typeof e=="function"&&(e=e()),e&&!/^wss?:/i.test(e)){const t=document.createElement("a");return t.href=e,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return e}function Pi(e=xi("url")||ee.default_mount_path){return new Li(e)}function xi(e){const t=document.head.querySelector(`meta[name='action-cable-${e}']`);if(t)return t.getAttribute("content")}function _t(e){var t,i;const n=((t=performance==null?void 0:performance.getEntriesByType)==null?void 0:t.call(performance,"navigation"))||[];return e.type==="pageshow"&&(e.persisted||((i=n[0])==null?void 0:i.type)==="back_forward")}let E,ne,re;U.staleThreshold=10,U.reconnectionBackoffRate=.2;const Fi=(e,t)=>{if((ne!==t||re!==e)&&(E==null||E.disconnect(),E=void 0),!E){const i=`${pi.replace("https","wss")}/cable?profile_id=${e}&project_slug=${t}`;E=Pi(i),ne=t,re=e}return E};window.addEventListener("pagehide",()=>{var e,t;E&&(E.disconnect(),(t=(e=E.connection)==null?void 0:e.webSocket)==null||t.close())},{capture:!0}),window.addEventListener("pageshow",e=>{E&&_t(e)&&E.connection.reopen()},{capture:!0});function Ri(e,t,i){return e.subscriptions.create({channel:"ProfileChannel",sid:t.session.id},{isConnected:!1,connected(){this.isConnected=!0},disconnected(){this.isConnected=!1},rejected(){this.isConnected=!1},received:i})}const Di="1.29.0";function St(e,t){return new Promise(i=>{const n=async()=>{e&&await e(),i()},r=t||document;r.readyState==="complete"||r.readyState==="interactive"?setTimeout(n,0):r.addEventListener("DOMContentLoaded",n)})}function qi(e){return e=e==null?void 0:e.trim(),!e||e.length%4!==0?!1:/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}function x(e,t,i){const n=typeof t=="function"?t:void 0,r=(typeof t=="object"?t:i)||{},{timeout:s=100,retries:o=30,alwaysResolve:a=!1,backoff:c=!0}=r;let u=s;return new Promise((l,d)=>{let f=0;const h=()=>{typeof n=="function"&&n(),l()},b=async()=>{if(f>=o){a&&h();return}f++,c&&f>1&&(u+=s);try{await e()?h():setTimeout(b,u)}catch{setTimeout(b,u)}};b()})}/*! js-cookie v3.0.1 | MIT */function tt(e){for(var t=1;t=0;--s)r.push(i.slice(s).join("."));return r}function At(e){const t=Bi(e);for(let i=0;i$i}function Hi(e){return new Date().getTime()-e.lastTouched256){for(rt=Array(e=256);e--;)rt[e]=256*Math.random()|0;e=F=0}for(;e<16;e++)t=rt[F+e],e==6?i+=nt[t&15|64]:e==8?i+=nt[t&63|128]:i+=nt[t],e&1&&e>1&&e<11&&(i+="-");return F++,i}const Ji="[object RegExp]",Qi="[object String]",Xi="[object Number]",Zi="[object Boolean]",he="[object Arguments]",Yi="[object Symbol]",tn="[object Date]",en="[object Map]",nn="[object Set]",rn="[object Array]",sn="[object Function]",on="[object ArrayBuffer]",Ot="[object Object]",an="[object Error]",cn="[object DataView]",un="[object Uint8Array]",ln="[object Uint8ClampedArray]",dn="[object Uint16Array]",fn="[object Uint32Array]",hn="[object BigUint64Array]",mn="[object Int8Array]",gn="[object Int16Array]",pn="[object Int32Array]",wn="[object BigInt64Array]",vn="[object Float32Array]",yn="[object Float64Array]";function me(e){return Object.getOwnPropertySymbols(e).filter(t=>e.propertyIsEnumerable(t))}function ge(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}function pe(e){if(typeof e!="object"||e==null)return!1;if(Object.getPrototypeOf(e)===null)return!0;if(e.toString()!=="[object Object]")return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function bn(e,t){if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return e===t;case"number":return e===t||Object.is(e,t);case"function":return e===t;case"object":return L(e,t)}return L(e,t)}function L(e,t,i){if(Object.is(e,t))return!0;let n=ge(e),r=ge(t);if(n===he&&(n=Ot),r===he&&(r=Ot),n!==r)return!1;switch(n){case Qi:return e.toString()===t.toString();case Xi:{const a=e.valueOf(),c=t.valueOf();return a===c||Number.isNaN(a)&&Number.isNaN(c)}case Zi:case tn:case Yi:return Object.is(e.valueOf(),t.valueOf());case Ji:return e.source===t.source&&e.flags===t.flags;case sn:return e==t}i=i!=null?i:new Map;const s=i.get(e),o=i.get(t);if(s!=null&&o!=null)return s===t;i.set(e,t),i.set(t,e);try{switch(n){case en:{if(e.size!==t.size)return!1;for(const[a,c]of e.entries())if(!t.has(a)||!L(c,t.get(a),i))return!1;return!0}case nn:{if(e.size!==t.size)return!1;const a=Array.from(e.values()),c=Array.from(t.values());for(let u=0;uL(l,f,i));if(d===-1)return!1;c.splice(d,1)}return!0}case rn:case un:case ln:case dn:case fn:case hn:case mn:case gn:case pn:case wn:case vn:case yn:{if(typeof Buffer!="undefined"&&Buffer.isBuffer(e)!==Buffer.isBuffer(t)||e.length!==t.length)return!1;for(let a=0;a{bn(i[r],n[r])&&delete n[r]}),n}userInfo(){return{id:this.id(),traits:this.traits()}}reset(){window.localStorage.removeItem(R),window.localStorage.removeItem(jt),window.localStorage.removeItem(q),z(R,this.cookieDefaults),z(q,this.cookieDefaults)}}const It=e=>{var t;return new Lt({cookies:(t=e==null?void 0:e.sdk_settings)==null?void 0:t.cookie_defaults})};function Tn(){const e=window.navigator.userAgent;return/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(e)?"tablet":/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(e)?"mobile":"desktop"}function An(){try{return it()}catch{}}function En(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{}}class Cn{constructor(t){this.current=n=>{const r=n==="page"?void 0:An(),s=window.ko;return{page:r,userAgent:window.navigator.userAgent,platform:{name:window.navigator.platform,deviceType:Tn()},library:{name:"koala",version:s==null?void 0:s.version},session:this.session(),locale:window.navigator.language,timezone:En()}};var i;this.options=t||{},this.user=new Lt({cookies:(i=this.options.sdk_settings)==null?void 0:i.cookie_defaults})}session(){return Ct.fetch(this.options.sdk_settings)}}class at{constructor(){this.callbacks={}}on(t,i){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(i),this}once(t,i){const n=(...r)=>{this.off(t,n),i.apply(this,r)};return this.on(t,n),this}off(t,i){const n=this.callbacks[t];if(n){const r=n.filter(s=>s!==i);this.callbacks[t]=r}return this}emit(t,...i){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,i)),this}removeListeners(){this.callbacks={}}}function kn(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}const ct=kn;var On=typeof global=="object"&&global&&global.Object===Object&&global;const jn=On;var Ln=typeof self=="object"&&self&&self.Object===Object&&self,In=jn||Ln||Function("return this")();const ve=In;var Pn=function(){return ve.Date.now()};const Pt=Pn;var xn=/\s/;function Fn(e){for(var t=e.length;t--&&xn.test(e.charAt(t)););return t}const Rn=Fn;var Dn=/^\s+/;function qn(e){return e&&e.slice(0,Rn(e)+1).replace(Dn,"")}const Mn=qn;var Nn=ve.Symbol;const ut=Nn;var ye=Object.prototype,Bn=ye.hasOwnProperty,Un=ye.toString,H=ut?ut.toStringTag:void 0;function $n(e){var t=Bn.call(e,H),i=e[H];try{e[H]=void 0;var n=!0}catch{}var r=Un.call(e);return n&&(t?e[H]=i:delete e[H]),r}const zn=$n;var Hn=Object.prototype,Kn=Hn.toString;function Wn(e){return Kn.call(e)}const Vn=Wn;var Gn="[object Null]",Jn="[object Undefined]",be=ut?ut.toStringTag:void 0;function Qn(e){return e==null?e===void 0?Jn:Gn:be&&be in Object(e)?zn(e):Vn(e)}const Xn=Qn;function Zn(e){return e!=null&&typeof e=="object"}const Yn=Zn;var tr="[object Symbol]";function er(e){return typeof e=="symbol"||Yn(e)&&Xn(e)==tr}const ir=er;var _e=NaN,nr=/^[-+]0x[0-9a-f]+$/i,rr=/^0b[01]+$/i,sr=/^0o[0-7]+$/i,or=parseInt;function ar(e){if(typeof e=="number")return e;if(ir(e))return _e;if(ct(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=ct(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=Mn(e);var i=rr.test(e);return i||sr.test(e)?or(e.slice(2),i?2:8):nr.test(e)?_e:+e}const Se=ar;var cr="Expected a function",ur=Math.max,lr=Math.min;function dr(e,t,i){var n,r,s,o,a,c,u=0,l=!1,d=!1,f=!0;if(typeof e!="function")throw new TypeError(cr);t=Se(t)||0,ct(i)&&(l=!!i.leading,d="maxWait"in i,s=d?ur(Se(i.maxWait)||0,t):s,f="trailing"in i?!!i.trailing:f);function h(g){var P=n,K=r;return n=r=void 0,u=g,o=e.apply(K,P),o}function b(g){return u=g,a=setTimeout(k,t),l?h(g):o}function C(g){var P=g-c,K=g-u,Re=t-P;return d?lr(Re,s-K):Re}function w(g){var P=g-c,K=g-u;return c===void 0||P>=t||P<0||d&&K>=s}function k(){var g=Pt();if(w(g))return Fe(g);a=setTimeout(k,C(g))}function Fe(g){return a=void 0,f&&n?h(g):(n=r=void 0,o)}function rs(){a!==void 0&&clearTimeout(a),u=0,n=c=r=a=void 0}function ss(){return a===void 0?o:Fe(Pt())}function qt(){var g=Pt(),P=w(g);if(n=arguments,r=this,c=g,P){if(a===void 0)return b(c);if(d)return clearTimeout(a),a=setTimeout(k,t),h(c)}return a===void 0&&(a=setTimeout(k,t)),o}return qt.cancel=rs,qt.flush=ss,qt}const fr=dr;var hr="Expected a function";function mr(e,t,i){var n=!0,r=!0;if(typeof e!="function")throw new TypeError(hr);return ct(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),fr(e,t,{leading:n,maxWait:t,trailing:r})}const xt=mr;function gr(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"&&typeof e.catch=="function"}class Te extends at{constructor(t={}){super(),this.flushed=[],this.queue=new Set,this.flushing=!1,t.onSend&&(this.onSend=t.onSend),this.scheduleSend=xt(this.send,t.flushInterval||1e4,{leading:!1,trailing:!0})}add(t){this.queue.add(t),this.scheduleSend()}flush(){this.scheduleSend.flush()}get all(){return this.flushed.concat(Array.from(this.queue))}reset(){this.queue.clear(),this.flushed.length=0}onSend(t){return!0}send(t=!1){if(this.flushing&&!t){setTimeout(()=>this.scheduleSend(),0);return}try{if(this.flushing=!0,this.queue.size){const i=Array.from(this.queue),n=this.onSend(i),r=s=>{s!==!1&&(this.flushed.push(...i),this.queue.clear(),this.emit("processed",i))};gr(n)?n.then(r).finally(()=>{this.flushing=!1}):r(n)}}finally{this.flushing=!1}}}class pr extends Te{constructor(t={},i,n){super(t),this.events=[],this.projectSlug=i,this.context=n}track(t,i={},n="track",r={}){const s={context:{...this.context.current("event"),...r},message_id:st(),type:n,event:t,properties:i,sent_at:new Date().toISOString()};this.events.push(s),this.add(s)}reset(){this.queue.clear(),this.flushed.length=0,this.events=[]}onSend(t=[]){const i=this.context.user.id(),n=this.projectSlug;return!n||!i?!1:Si(n,i,t)}}var us=S(639);const wr=/[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g;function Ft(e){var t;return Array.from((t=e.match(wr))!=null?t:[])}const vr=e=>Ft(e).map(i=>i.toLowerCase()).join("_"),Ae=e=>Ft(e).map(i=>i.toLowerCase()).join(" "),yr=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase();function Ee(e){const t=Ft(e);if(t.length===0)return"";const[i,...n]=t;return`${i.toLowerCase()}${n.map(r=>yr(r)).join("")}`}let lt;const Rt=["captcha","card","cc","ccn","credit","cvv","password","payable","pin","pw","receivable","routing","secret","security","ssn","token","account"].flatMap(e=>[e.toLowerCase(),vr(e),Ae(e)]),br=["email","name","phone","phoneNumber","firstName","lastName","fullName","title","username","website","domain","company"];function _r(e,t){let i=e;for(;i&&!(t(i)||(i=i.parentElement,!i||i.tagName==="FORM")););return i}function dt(e){var t,i;return((t=e==null?void 0:e.innerText)==null?void 0:t.trim())||((i=e==null?void 0:e.textContent)==null?void 0:i.trim())}function Sr(e,t){let i;if(e.labels&&e.labels.length){const[n,...r]=Array.from(e.labels);i=dt(n)}if(!i){const n=[e.previousElementSibling,e.nextElementSibling].filter(r=>(r==null?void 0:r.tagName)==="LABEL"&&dt(r));n.length&&(i=dt(n[0]))}if(!i){const n=_r(e,r=>{const s=r.querySelectorAll("label").length>0,o=t.every(a=>a===e||!r.contains(a));return s&&o});n&&n.tagName!=="FORM"&&(i=dt(n.querySelector("label")))}return Ee(i||"")}function Tr(e,t){const i=e.tagName.toLowerCase(),n=e.type,r=e.id?`#${e.id}`:"",s=e.className?`.${e.className}`:"";return`${i}_${t}_${[n,r,s].filter(Boolean).join("_")}`}function Ar(e){const t={},i=Array.from(e.elements);for(const n of i){if(!n.value||!["INPUT","SELECT","TEXTAREA"].includes(n.tagName)||["checkbox","radio"].includes(n.type)&&!n.checked||n.type==="password"||n.type==="hidden"||n.type==="submit"||n.name&&Rt.some(a=>n.name.toLowerCase().includes(a))||n.id&&Rt.some(a=>n.id.toLowerCase().includes(a)))continue;const r=Sr(n,i);if(r&&Rt.some(a=>r.toLowerCase().includes(a)))continue;const s=n.id||Tr(n,i.indexOf(n)),o=[n.name,r,s].filter(Boolean);for(const a of o)if(!t[a]){t[a]={id:s,label:r,name:n.name,type:n.type,tagName:n.tagName,value:n.value};break}}return t}function Er(e){const t={};for(const[i,n]of Object.entries(e))t[i]=n.value;return t}function ft(e){const t=document.createElement("input");return t.type="email",t.required=!0,t.value=String(e),t.checkValidity()}function Cr(e){return Object.entries(e).filter(([t,i])=>{var n,r,s,o,a,c;return i.type==="email"||(r=(n=i.name)==null?void 0:n.toLowerCase())!=null&&r.includes("email")||(o=(s=i.label)==null?void 0:s.toLowerCase())!=null&&o.includes("email")||(c=(a=i.id)==null?void 0:a.toLowerCase())!=null&&c.includes("email")?ft(i.value):!1}).map(([t])=>t)}function kr(e){const t={},i=Cr(e),n=i.length===1;for(const[r,s]of Object.entries(e)){if(n&&i[0]===r){t.email=s.value;continue}const a=[s.name,s.label,s.id].filter(Boolean).map(c=>Ee(Ae(c||"").replace(/^(your|work|business|job)(\s+)/i,""))).find(c=>br.includes(c)&&!t[c]);a&&a!=="email"&&s.value&&(t[a]=s.value)}return t.email||t.firstName&&t.lastName?t:{}}function Or(e,t={}){Ce();const i=async o=>{const a=o instanceof HTMLFormElement,c=o.tagName,u=a||c==="FORM";if(o.getAttribute("data-koala-collect")==="off"||!u)return;const d=it();if((t.ignoredForms||[]).some(k=>k.identifier_type==="path"&&k.identifier===d.path))return;const h=Ar(o),b=Er(h),C=kr(h),w=o.getAttribute("data-koala-selector")||o.getAttribute("id")||o.className;try{await e({context:{page:d,selector:w},name:o.getAttribute("name")||o.id,method:o.method,action:o.action,formData:b,traits:C})}catch{}},n=async o=>{try{const a=o.target;if(typeof a.requestSubmit=="function"){o.preventDefault(),o.stopPropagation(),await i(a);const c=a.querySelector("button[type=submit], input[type=submit]"),u=o.currentTarget;setTimeout(()=>{c?a.requestSubmit(c):a.requestSubmit(),u==null||u.addEventListener("submit",n,{capture:!0,once:!0})},0)}else{await i(a);const c=o.currentTarget;c==null||c.addEventListener("submit",n,{capture:!0,once:!0})}}catch{}};document.addEventListener("submit",n,{capture:!0,once:!0});const r=document.querySelectorAll("iframe");r.forEach(o=>{const a=o.contentDocument;a&&St(()=>{a.addEventListener("submit",n,{capture:!0,once:!0})},a)});const s=HTMLFormElement.prototype.submit;return HTMLFormElement.prototype.submit=async function(){try{await i(this)}catch{}s.call(this)},lt=()=>{document.removeEventListener("submit",n,{capture:!0}),r.forEach(o=>{const a=o.contentDocument;a&&St(()=>{a.removeEventListener("submit",n,{capture:!0})},a)}),HTMLFormElement.prototype.submit=s},lt}function Ce(){lt&<()}function jr({project:e,...t}){return N(`/web/projects/${e}/metrics`,t)}class Lr extends Te{constructor(t={},i,n){super(t),this.projectSlug=i,this.context=n}increment(t,i){this.add({context:this.context.current("metric"),id:st(),name:t,properties:i,sent_at:new Date})}onSend(t=[]){const i=this.context.user.id(),n=this.projectSlug;return!n||!i?!1:jr({project:n,profile_id:i,metrics:t})}}function Ir(e,t){try{return e=new URL(e,window.location.origin),t=new URL(t||window.location.href,window.location.origin),e.hostname===t.hostname&&e.pathname===t.pathname}catch{return!1}}function Pr(e){const{top:t,left:i,right:n,bottom:r}=e.getBoundingClientRect(),s=e.offsetWidth,o=e.offsetHeight;return t>=-o&&i>=-s&&n<=(window.innerWidth||document.documentElement.clientWidth)+s&&r<=(window.innerHeight||document.documentElement.clientHeight)+o}class xr extends at{constructor(t={}){super(),this.isFocused=!1,this.checkIdleIntervalMs=1e3,this.registered=!1,this.interacted=!1,this.startAutocapture=()=>{!document.hidden&&!this.isFocused&&this.startFocus(),this.registerListeners()},this.stopAutocapture=()=>{this.unregisterListeners(),this.endFocus()},this.restart=()=>{this.isFocused&&this.endFocus(),document.hidden||this.startFocus()},this.registerListeners=()=>{this.registered||(this.registered=!0,document.addEventListener("visibilitychange",this.onVisibilityChangeWrapper),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.onFocus),window.addEventListener("scroll",this.pulse,{capture:!0,passive:!0}),document.addEventListener("mousedown",this.pulse,{passive:!0}),document.addEventListener("mousemove",this.pulse,{passive:!0}),document.addEventListener("touchstart",this.pulse,{passive:!0}),document.addEventListener("touchmove",this.pulse,{passive:!0}),document.addEventListener("keydown",this.pulse,{passive:!0}),document.addEventListener("keyup",this.pulse,{passive:!0}),document.addEventListener("click",this.pulse,{passive:!0}),document.addEventListener("contextmenu",this.pulse,{passive:!0}),document.addEventListener("play",this.pulse,{capture:!0,passive:!0}),window.addEventListener("pageshow",this.onBfCacheRestore),this.checkMedia(),this.checkIdleTime())},this.unregisterListeners=()=>{this.registered&&(window.clearTimeout(this.idleIntervalCheck),window.clearTimeout(this.idleMediaTimer),window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.onFocus),window.removeEventListener("scroll",this.pulse,{capture:!0}),document.removeEventListener("visibilitychange",this.onVisibilityChangeWrapper),document.removeEventListener("mousedown",this.pulse),document.removeEventListener("mousemove",this.pulse),document.removeEventListener("touchstart",this.pulse),document.removeEventListener("touchmove",this.pulse),document.removeEventListener("keydown",this.pulse),document.removeEventListener("keyup",this.pulse),document.removeEventListener("click",this.pulse),document.removeEventListener("contextmenu",this.pulse),document.removeEventListener("play",this.pulse,{capture:!0}),window.removeEventListener("pageshow",this.onBfCacheRestore),this.registered=!1)},this.onBfCacheRestore=i=>{_t(i)&&document.visibilityState==="visible"&&(this.startFocus(),this.checkMedia(),this.checkIdleTime())},this.startFocus=()=>{const i=performance.now();this.isFocused=!0,this.focusStart=i,this.lastFocusStart=i,this.emit("focus_time.start",this.focusStart)},this.endFocus=()=>{this.pulse.cancel(),this.emit("focus_time.end",this.currentFocusTime),this.isFocused=!1},this.onVisibilityChangeWrapper=()=>this.onVisibilityChange(document.visibilityState),this.checkIdleTime=()=>{window.clearTimeout(this.idleIntervalCheck),this.pulse.flush(),this.idleTime>=this.idleInterval&&this.endFocus(),this.idleIntervalCheck=window.setTimeout(()=>this.checkIdleTime(),this.checkIdleIntervalMs)},this.onBlur=()=>{this.isFocused&&this.endFocus()},this.onFocus=()=>{this.isFocused||this.startFocus()},this.onVisibilityChange=i=>{i==="visible"?this.onFocus():i==="hidden"&&this.onBlur()},this.pulse=xt(()=>{this.interacted=!0,this.isFocused?this.lastFocusStart=performance.now():this.startFocus()},500,{leading:!0,trailing:!0}),this.checkMedia=()=>{window.clearTimeout(this.idleMediaTimer);const i=document.querySelectorAll("video");Array.from(i).filter(r=>r.paused||r.loop||r.muted&&!r.controls||r.readyState<2?!1:Pr(r)).length>0&&document.visibilityState==="visible"&&this.pulse(),this.idleMediaTimer=window.setTimeout(()=>this.checkMedia(),this.checkIdleIntervalMs)},this.isFocused=!1,this.idleInterval=t.idleInterval||15e3,this.checkIdleIntervalMs=t.checkIdleIntervalMs||1e3,t.start!==!1&&this.startAutocapture()}get idleTime(){return this.isFocused&&typeof this.lastFocusStart=="number"?performance.now()-this.lastFocusStart:0}get currentFocusTime(){return this.interacted&&this.isFocused&&typeof this.focusStart=="number"?performance.now()-this.focusStart:0}clear(){this.restart()}}const Fr=60*60*1e3;function Rr(e){const t=history.pushState;history.pushState=(...n)=>{t.apply(history,n),e.emit("page_tracker.push")};const i=history.replaceState;history.replaceState=(...n)=>{i.apply(history,n),e.emit("page_tracker.replace",...n)},window.addEventListener("popstate",()=>{e.emit("page_tracker.pop")})}class Dr extends at{constructor(t){var i,n,r;super(),this.pages=[],this.collecting=!1,this.collectedSomeFocus=!1,this.autocapture=!0,this.registered=!1,this.startAutocapture=()=>{this.registered||(this.registered=!0,this.on("page_tracker.push",this.collect),this.on("page_tracker.replace",this.onReplaceState),this.on("page_tracker.pop",this.collect),document.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("focus",this.onVisibilityChange),window.addEventListener("pageshow",this.onPageShow),window.addEventListener("pagehide",this.onPageHide,{capture:!0}),this.focusTimer.on("focus_time.end",this.recordFocusTime),this.focusTimer.startAutocapture(),setTimeout(()=>{this.collect()},0))},this.stopAutocapture=()=>{this.registered&&(this.registered=!1,this.off("page_tracker.push",this.collect),this.off("page_tracker.replace",this.onReplaceState),this.off("page_tracker.pop",this.collect),document.removeEventListener("visibilitychange",this.onVisibilityChange),window.removeEventListener("focus",this.onVisibilityChange),window.removeEventListener("pageshow",this.onPageShow),window.removeEventListener("pagehide",this.onPageHide,{capture:!0}),this.focusTimer.off("focus_time.end",this.recordFocusTime),this.focusTimer.stopAutocapture())},this.allPages=()=>this.pages,this.onReplaceState=(s,o,a)=>{var c,u;const l=(u=(c=this.currentPage)==null?void 0:c.page)==null?void 0:u.url,d=a&&!Ir(a,l);(!l||d)&&this.collect()},this.onVisibilityChange=()=>{var s,o,a,c,u;if(document.visibilityState==="visible"){const l=this.context.session(),d=(a=(o=(s=this.currentPage)==null?void 0:s.context)==null?void 0:o.session)==null?void 0:a.id,f=new Date().getTime(),h=(u=(c=this.currentPage)==null?void 0:c.visit_start)==null?void 0:u.getTime();d!==l.id?this.collect():(!h||Math.abs(f-h)>=Fr)&&this.collect()}},this.makePage=()=>({context:this.context.current("page"),message_id:st(),page:it(),visit_start:new Date,focus_intervals:[]}),this.collect=()=>{this.collecting=!0;const s=this.endCurrentPage({emit:!1}),o=this.makePage();this.pages.push(o),this.collectedSomeFocus=!1;const a=[s,o].filter(Boolean);this.emit("page",a),this.collecting=!1},this.endCurrentPage=s=>{const o=this.currentPage;if(o&&(window.clearTimeout(this.collectFocusTimeout),this.collectFocusTimeout=void 0,this.focusTimer.restart(),!o.visit_end))return o.visit_end=new Date,(s==null?void 0:s.emit)!==!1&&this.emit("page",[o]),o},this.onPageShow=s=>{_t(s)&&(this.pages=[],this.collect())},this.onPageHide=()=>{this.collecting=!0,this.endCurrentPage(),this.collecting=!1},this.recordFocusTime=s=>{const o=this.currentPage;if(s=Math.round(s||0),o&&s){if(o.focus_intervals.push(s),this.emit("new_focus_time"),this.collecting||this.collectFocusTimeout)return;const a=o.focus_intervals.reduce((d,f)=>d+f,0),c=!this.collectedSomeFocus&&a>=1e3,u=o.focus_intervals.length%3==0,l=s>=1e4;(c||u||l)&&(this.collectFocusTimeout=window.setTimeout(()=>{this.collectFocusTimeout=void 0,this.collectedSomeFocus=!0,this.emit("page",[o])},2e3))}},this.context=t,this.autocapture=(r=(n=(i=t.options)==null?void 0:i.sdk_settings)==null?void 0:n.autocapture)!=null?r:!0,this.focusTimer=new xr({start:this.autocapture}),Rr(this),this.onVisibilityChange=xt(this.onVisibilityChange.bind(this),100,{leading:!0,trailing:!1}),this.autocapture&&this.startAutocapture()}get currentPage(){return this.pages[this.pages.length-1]}get currentFocusTime(){var t;return this.focusTimer.currentFocusTime+(((t=this.currentPage)==null?void 0:t.focus_intervals.reduce((i,n)=>i+n,0))||0)}get currentIdleTime(){return this.focusTimer.idleTime||0}get sessionFocusTime(){return this.focusTimer.currentFocusTime+this.pages.reduce((t,i)=>t+i.focus_intervals.reduce((n,r)=>n+r,0),0)}get scheduled(){return!!this.collectFocusTimeout}reset(){this.pages=[],this.focusTimer.clear()}}function qr(e){window.addEventListener("message",t=>{t.origin==="https://demo.arcade.software"&&e&&t.data&&t.data.eventName&&e.track("Arcade "+t.data.eventName,t.data,{source:"arcade"})},!1)}function Mr(e){const t=()=>typeof window.drift!="undefined"&&typeof window.drift.on=="function",i=(r,s)=>{try{s()}catch(o){e==null||e.trackError(o,`drift.${r}`)}};x(t,()=>{t()&&window.drift.on("ready",()=>{window.drift.on("emailCapture",r=>{i("emailCapture",()=>{e&&!e.email&&r&&r.data&&r.data.email&&(e.identify({email:r.data.email},{source:"drift"}),e.track("Drift Email Captured",r.data,{source:"drift"}))})}),window.drift.on("phoneCapture",r=>{i("phoneCapture",()=>{e&&r&&r.phone&&(e.identify({phone:r.phone},{source:"drift"}),e.track("Drift Phone Captured",r,{source:"drift"}))})}),window.drift.on("startConversation",r=>{i("startConversation",()=>{if(e&&r){const s={};r.endUserEmail&&(s.email=r.endUserEmail),r.endUserId&&(s.drift__contact_id=r.endUserId),e.email||e.identify(s,{source:"drift"}),e.track("Drift Conversation Started",r,{source:"drift"})}})}),window.drift.on("scheduling:meetingBooked",r=>{i("scheduling:meetingBooked",()=>{e&&r&&e.track("Drift Meeting Booked",r,{source:"drift"})})})})},{timeout:500,retries:10})}function Nr(e){x(()=>typeof window.FS=="function",()=>{window.FS("observe",{type:"start",callback:()=>{const n=window.FS("getSession",{format:"url"});n&&e.identify({fullstory_session_url:n},{source:"fullstory"})}}),window.addEventListener("fullstory/rageclick",n=>{var r;e.track("Rage Click Detected",{replay_url:(r=n==null?void 0:n.detail)==null?void 0:r.eventReplayUrlAtCurrentTime},{source:"fullstory"})})},{timeout:100,retries:10})}const ke={email:"email",jobtitle:"title",hs_role:"role",phone:"phone",mobilephone:"mobile_phone",lastname:"last_name",firstname:"first_name",fullname:"name",twitterhandle:"twitter_handle",hs_linkedin_url:"linkedin_url"},Br=Object.keys(ke);function Ur(e){window.addEventListener("message",t=>{var i,n,r,s;if(!e||!t.data)return!1;try{if(t.data.type==="hsFormCallback"&&t.data.eventName==="onFormSubmitted"){const o=t.data.id,a=t.data.data;if(!a||!a.submissionValues||!o)return;const c={},u={...a.submissionValues};delete u.hs_context;for(const d of Br)u[d]&&(c[ke[d]]=u[d]);const l=c.email;(!e.email||l==e.email)&&e.identify(c,{source:"hubspot_form"}),e.track("$submit",{method:"POST",name:`#hsForm_${o}`,formData:u,traits:c,context:{page:it()}})}else if(t.data.meetingBookSucceeded){const o=((i=t.data.meetingsPayload)==null?void 0:i.bookingResponse)||{},a=(n=o.postResponse)==null?void 0:n.contact,c=a==null?void 0:a.email;c&&!e.email&&e.identify({email:c},{source:"hubspot_meeting"}),e.track("Meeting Booked",{integration:"HubSpot",contact:a,organizer:(r=o.postResponse)==null?void 0:r.organizer,meeting_date:(s=o.event)==null?void 0:s.dateString},{source:"hubspot_meeting"})}}catch(o){e==null||e.trackError(o,"initHubSpot")}})}function $r(e){x(()=>typeof window.Intercom=="function",()=>{const n=window.Intercom("getVisitorId");e&&n&&e.identify({intercom__visitor_id:n},{source:"intercom"}),window.Intercom("onUserEmailSupplied",()=>{var r;try{const s=(r=document.querySelector(".intercom-messenger-frame"))==null?void 0:r.children[0];s&&e&&!e.email&&setTimeout(()=>{var o;const a=s.contentDocument,c=(o=a==null?void 0:a.body.querySelector('input[type="email"]'))==null?void 0:o.value;c&&e.identify({email:c},{source:"intercom"})},100)}catch(s){e==null||e.trackError(s,"intercom.onUserEmailSupplied")}})},{timeout:100,retries:10})}const zr={VIEW_STEP:"Step Viewed",START_FLOW:"Flow Started",COMPLETE_FLOW:"Flow Completed",START_CHECKLIST:"Checklist Started",OPEN_CHECKLIST:"Checklist Opened",CLOSE_CHECKLIST:"Checklist Closed",COMPLETE_TASK:"Task Completed",CONVERTED:"User Converted",NAVIGATE:"User Navigated",IDENTIFY_USER:"User Identified",ENGAGE:"User Engaged"};function Hr(e){x(()=>typeof window.navattic!="undefined"&&typeof window.navattic.onEvent=="function",()=>{window.navattic.onEvent(n=>{if(e)try{if(n.type==="IDENTIFY_USER"&&n.attributes&&!e.email){const r=n.attributes["user.email"]||n.attributes.email;r&&e.identify({email:r},{source:"navattic"})}n.type&&e.track("Navattic "+(zr[n.type]||n.type),n,{source:"navattic"})}catch(r){e==null||e.trackError(r,"navattic.onEvent")}})},{timeout:500,retries:20})}function Kr(e){x(()=>typeof window.posthog=="object"&&typeof window.posthog.get_session_replay_url=="function",()=>{const n=window.posthog.get_session_replay_url();n&&e.identify({posthog_session_url:n,posthog_session_id:window.posthog.get_session_id(),posthog_distinct_id:window.posthog.get_distinct_id()},{source:"posthog"})},{timeout:100,retries:10})}function Wr(e){const t=()=>typeof window.qualified=="function";x(t,()=>{t()&&window.qualified("handleEvents",(n,r)=>{try{if(!e)return;if(r&&r.field_values&&!e.email){const s=r.field_values.email;s&&e.identify({email:s},{source:"qualified"})}e.track("Qualified "+n,r,{source:"qualified"})}catch(s){e==null||e.trackError(s,"qualified.handleEvents")}})},{timeout:100,retries:10})}function Vr(e){return e.origin==="https://calendly.com"&&e.data.event&&e.data.event.indexOf("calendly.")===0}function Gr(e){window.addEventListener("message",t=>{if(!e||!t.data||!Vr(t))return!1;if(t.data.event==="calendly.event_scheduled"){const n=t.data.payload||{};e.track("Calendly Event Scheduled",n,{source:"calendly"})}})}const Oe={demo_open:"Demo Opened",demo_finished:"Demo Finished",lead_identify:"Lead Identified",step_view:"Step Viewed",open_external_url:"External URL Opened",checklist_item_view:"Checklist Item Viewed",flow_start:"Flow Started",flow_end:"Flow Ended",page_view:"Page Viewed",primary_cta:"Primary CTA Clicked",secondary_cta:"Secondary CTA Clicked",convert_cta:"Convert CTA Clicked"};function Jr(e){return e.data.message==="storylane-demo-event"}function Qr(e){window.addEventListener("message",t=>{var i;try{if(!e||!t.data||!Jr(t))return!1;const n=t.data.payload||{},r=n.event;r==="lead_identify"&&!e.email&&((i=n.lead)!=null&&i.email)?e.identify(n.lead,{source:"storylane"}):Oe[r]&&e.track("Storylane "+Oe[r],n,{source:"storylane"})}catch(n){e==null||e.trackError(n,"initStorylane")}})}const je=window.location.search;let Le=window.location.hostname;try{Le=At(new URL(window.location.href))||window.location.hostname}catch{}function Xr(e){if(e.length===0)return!0;const t=window.location.host;return e.some(n=>{try{return new RegExp(n).test(t)}catch{return!0}})}const Dt=(e,t)=>(...i)=>t(e,...i);class Zr extends at{constructor(t){var i,n,r,s,o,a;super(),this.version=Di,this.initialized=!1,this.subscription=null,this.autocapture=!0,this.referrerAllowed=!0,this.geoAllowed=!0,this.collectForms=(f={})=>{const h=[Le,"salesforce.com","pardot.com","list-manage.com"];Or(async b=>{let C=!0;if(b.action){const w=new URL(b.action);w.hostname&&(C=h.some(k=>w.hostname.endsWith(k)))}if(C){Object.keys(b.formData).length>0&&this.track("$submit",b);const w={...b.traits};w.email?w.email=w.email.trim().toLowerCase():delete w.email,Object.keys(w).length>0&&(!w.email||!this.email||w.email===this.email)&&this.identify(w,{source:"form"})}},f)},this.initPlugins=()=>{var f;const h=((f=this.options)==null?void 0:f.sdk_settings)||{};Ur(this),h.autotrack_arcade&&qr(this),h.autotrack_calendly&&Gr(this),h.autotrack_drift&&Mr(this),h.autotrack_intercom&&$r(this),h.autotrack_navattic&&Hr(this),h.autotrack_qualified&&Wr(this),h.autotrack_fullstory&&Nr(this),h.autotrack_posthog_screen_recording&&Kr(this),h.autotrack_storylane&&Qr(this)},this.trackError=(f,h)=>{f&&this.stats.increment("sdk.error",{method:h||"general",message:f==null?void 0:f.message})},this.options=t,this.referrerAllowed=Xr(((i=t.sdk_settings)==null?void 0:i.authorized_referrers)||[]),this.geoAllowed=(r=(n=t.sdk_settings)==null?void 0:n.geo_allowed)!=null?r:!0,this.autocapture=this.referrerAllowed&&this.geoAllowed&&((o=(s=t.sdk_settings)==null?void 0:s.autocapture)!=null?o:!0);const c=this.options.project,u=this.deserialize();this.referrer=u.r||document.referrer,this.user=new Lt({cookies:(a=this.options.sdk_settings)==null?void 0:a.cookie_defaults}),this.context=new Cn(this.options),this.qualification=u.q;const l=this.options.a||u.a||{},d=u.rp||{};this.edge=vt(l),d&&(this.edge.rawProfile=d),this.stats=new Lr({flushInterval:1e3},c,this.context),this.eventQueue=new pr({flushInterval:1e3},c,this.context),this.pageTracker=new Dr(this.context),this.pageTracker.on("page",f=>{if(!(f!=null&&f.length)||!this.autocapture||!this.referrerAllowed||!this.geoAllowed)return;const h=f[f.length-1];this.edge.index(h);const b=()=>this.initialized&&!!this.user.id(),C=()=>{const w=this.user.id();Ti(c,w,f)};b()?C():this.when(b,C,{retries:10,alwaysResolve:!0})}),document.addEventListener("visibilitychange",()=>{document.hidden&&this.flush()}),t.hookSegment!==!1&&this.detectSegment(),this.detectRudder(),this.detectHubspot(),setTimeout(()=>{this.detectorStats()},5e3),this.once("initialized",f=>{var h;this.initialized=!0,this.bootstrapData=f,this.stats.increment("sdk.loaded",{page:window.location.pathname}),this.referrerAllowed||(console.warn("[KOALA]","Current domain not allowed to load the SDK"),this.stats.increment("sdk.referrer.blocked",{host:window.location.host})),this.geoAllowed||this.stats.increment("sdk.geo.blocked",{host:window.location.host}),this.detectIdLink(),this.autocapture&&this.initPlugins(),f.sdk_settings.querystring_collection!=="off"&&this.detectKoTraits(),this.autocapture&&f.sdk_settings.form_collection!=="off"&&this.collectForms({ignoredForms:((h=this.options.sdk_settings)==null?void 0:h.ignored_forms)||[]})})}async ready(t){return St(async()=>this.initialized||this.qualification?(t&&await t(),Promise.resolve(void 0)):new Promise(i=>{this.once("initialized",async()=>{t&&await t(),i(void 0)})}))}cookieDefaults(){var t;return((t=this.options.sdk_settings)==null?void 0:t.cookie_defaults)||{}}detectIdLink(){this.detectUtmId(),this.detectKoEmail()}detectKoTraits(){const t=new URLSearchParams(window.location.search),i=Array.from(t.entries()).filter(([n])=>n.startsWith("ko_trait_")).reduce((n,[r,s])=>{const o=r.replace("ko_trait_","");return n[o]=s,n},{});Object.keys(i).length>0&&this.identify(i,{source:"querystring"})}detectKoEmail(){const t=new URLSearchParams(je);let i=t.get("ko_e")||t.get("ko_email");if(i&&!this.email){i=i.trim();try{if(ft(i)){const n=t.get("k_is")||"ko_email";this.identify({email:i},{source:n})}}catch{}}}detectUtmId(){const t=new URLSearchParams(je),i=t.get("utm_id");if(i&&qi(i)&&!this.email)try{const n=atob(i.trim());if(ft(n)){const r=t.get("k_is")||"utm_id";this.identify({email:n},{source:r})}}catch{}}detectorStats(){var t,i,n,r,s,o;try{const a=window,c={"6sense":!!localStorage.getItem("_6senseCompanyDetails"),Albacross:!!((t=a.AlbacrossReveal)!=null&&t.company),Clearbit:!!a.reveal,Dealfront:!!((n=(i=a.discover)==null?void 0:i.data)!=null&&n.company),Demandbase:!!((s=(r=a.Demandbase)==null?void 0:r.Segments)!=null&&s.CompanyProfile),Drift:!!a.drift,Intercom:!!a.Intercom,Klaviyo:!!a.klaviyo,Marketo:!!a.MktoForms2,Leadoo:!!a.Leadoo,Pardot:!!a.getPardotUrl,Qualified:!!a.qualified,Rollworks:!!a.__adroll_loaded,Triblio:!!((o=a.Triblio)!=null&&o.getAccountIdentification()),ZoomInfo:!!localStorage.getItem("_ziVisitorInfo")};Object.keys(c).forEach(u=>{c[u]&&this.stats.increment(`sdk.${u}`)})}catch{}}flush(){this.serialize(),this.eventQueue.flush(),this.stats.flush()}stopAutocapture(){this.autocapture&&(this.autocapture=!1,this.pageTracker.stopAutocapture(),this.unsubscribe(),Ce())}startAutocapture(){var t,i;this.autocapture||(this.autocapture=!0,this.pageTracker.startAutocapture(),this.subscribe(),((t=this.options.sdk_settings)==null?void 0:t.form_collection)!=="off"&&this.collectForms({ignoredForms:((i=this.options.sdk_settings)==null?void 0:i.ignored_forms)||[]}))}get session(){return Ct.fetch(this.options.sdk_settings)}get email(){return this.user.email()}detectHubspot(){const t=()=>window._hstc_ran&&window._hsq&&window._hsq.push!==Array.prototype.push,i=()=>{try{const n=de("hubspotutk");n&&Ai({project:this.options.project,profile_id:this.user.id(),utk:n})}catch(n){console.warn("[KOALA]",n)}!window._hsq||window._ko_hsq||(window._ko_hsq=!0,window._hsq.push=Dt(window._hsq.push,(n,...r)=>{try{const s=r[0];if(Array.isArray(s)){const[o,a]=s;o==="identify"&&this.identify(a,{source:"hubspot_hsq"}),o==="trackCustomBehavioralEvent"&&!window.analytics&&this.track(a.name,a.properties)}return n.apply(window._hsq,r)}catch(s){console.warn("[KOALA] HubSpot wrap error:",s)}}))};this.when(t,i,{timeout:1e3,retries:10})}detectSegment(){const t=()=>typeof window.analytics!="undefined"&&typeof window.analytics.ready=="function",i=()=>{t()&&window.analytics.ready(()=>{const n=window.analytics,r=n.user().traits();this.identify(r,{source:"segment"}),n.on("invoke",()=>{const s=n.user().traits();this.identify(s,{source:"segment"})}),n.on("track",(s,o)=>{var a;((a=this.bootstrapData)==null?void 0:a.sdk_settings.segment_auto_track)!=="off"&&this.track(s,o)}),n.on("identify",(s,o)=>{this.identify(o,{source:"segment"})}),n.on("reset",()=>{this.reset()})})};this.when(t,i,{timeout:100,retries:20,alwaysResolve:!0})}detectRudder(){const t=()=>typeof window.rudderanalytics!="undefined"&&typeof window.rudderanalytics.ready=="function",i=()=>{t()&&window.rudderanalytics.ready(()=>{var n;const r=window.rudderanalytics,s=r.getUserTraits();let o={};if("getGroupTraits"in r&&(o=r.getGroupTraits()||{}),Object.keys(s).length>0){let a=s;Object.keys(o).length>0&&(a={...a,$account:o}),this.identify(a,{source:"rudderstack"})}((n=this.options.sdk_settings)==null?void 0:n.autotrack_rudderstack)!==!1&&(r.track=Dt(r.track,(a,...c)=>{const u=c[0],l=c[1];return typeof u=="string"&&this.track(u,l||{}).catch(d=>{console.warn("[KOALA]",d)}),a(...c)})),r.identify=Dt(r.identify,(a,...c)=>{const u=c[0],l=c[1]||{};return typeof u=="string"&&typeof l=="object"&&Object.keys(l).length>0&&this.identify(l,{source:"rudderstack"}).catch(d=>{console.warn("[KOALA]",d)}),a(...c)})})};this.when(t,i,{timeout:1e3,retries:10,alwaysResolve:!0})}async track(t,i={},n){if(t=t.trim(),!t||!this.referrerAllowed||!this.geoAllowed)return;const r=t==="$submit"?"submit":"track";this.eventQueue.track(t,i,r,n),this.edge.index({event:t,properties:i}),r==="submit"&&this.flush(),this.emit("track",t,i)}async identify(...t){if(!this.referrerAllowed||!this.geoAllowed)return;let i={},n={};if(typeof t[0]=="string"?(i={...t[1]||{},email:t[0]},n=t[2]||{}):(i=t[0],n=t[1]||{}),!i||Object.keys(i).length===0)return;const r=[i.email,i.email_address,i.emailAddress].filter(a=>a&&ft(a));r.length>0?i.email=String(r[0]).trim():delete i.email;const s=this.user.netNewTraits(i);if(i.email&&(s.email=i.email),Object.keys(s).length===0)return;this.email&&s.email&&s.email!=this.email&&this.reset(),this.user.upsertTraits(s),this.edge.index(s);const o={context:{...this.context.current("identify"),source:n.source||"identify"},type:"identify",traits:s,sent_at:new Date().toISOString()};_i(this.options.project,this.profile,o),this.emit("identify",this.user.id(),i)}subscribe(){var t,i,n;this.referrerAllowed&&this.geoAllowed&&((i=(t=this.bootstrapData)==null?void 0:t.sdk_settings)==null?void 0:i.websocket_connection)!=="off"&&((n=this.bootstrapData)==null?void 0:n.edge_api)!==!1&&this.when(()=>!!this.user.id()).then(()=>{const r=this.user.id(),s=this.options.project;this.unsubscribe();const o=Fi(r,s);this.subscription=Ri(o,this,a=>{a.action==="score"&&this.updateQualification(a.data),a.action==="anonymous_profile"&&this.buildAnonymousProfile(a.data),a.action==="edge_profile"&&(this.edge.rawProfile=a.data)})}).catch(r=>{console.warn("[KOALA]","Error subscribing to profile.",r)})}unsubscribe(){var t;(t=this.subscription)==null||t.unsubscribe(),this.subscription=null}buildAnonymousProfile(t){const i=this.edge.rawProfile;this.edge=vt(t||{}),i&&(this.edge.rawProfile=i),this.emit("profile-update")}updateQualification(t){const{profile_id:i,qualification:n,a:r}=t;this.qualification=n,this.emit("qualification",t),r&&this.buildAnonymousProfile(r),i!==this.user.id()&&(this.user.setId(i),this.emit("profile-id-update",i))}async qualify(t){try{t=t==null?void 0:t.trim(),t&&(this.user.upsertTraits({email:t}),this.edge.index({email:t}));const i=await bi(this.options.project,this.profile);return this.updateQualification(i),i}catch(i){throw this.trackError(i,"qualify"),i}}serialize(){const t={r:this.referrer,q:this.qualification,a:{b:this.edge.raw.bloom.toHash(),c:this.edge.raw.counts.toHash()},rp:this.edge.rawProfile};window.localStorage.setItem("ka",JSON.stringify(t))}deserialize(){const t=window.localStorage.getItem("ka")||"{}";return JSON.parse(t)}get profile(){return{page_views:this.pageTracker.allPages(),user:this.user.userInfo(),referrer:this.referrer,events:this.eventQueue.events,email:this.user.traits().email,traits:this.user.traits(),qualification:this.qualification}}async reset(){this.eventQueue.send(!0),this.eventQueue.reset(),this.stats.send(!0),this.stats.reset(),this.pageTracker.reset(),this.unsubscribe(),this.user.reset(),window.localStorage.removeItem("ka"),this.qualification=void 0,this.edge=vt({}),Ct.clear(),this.subscribe()}get when(){return x}get e(){return this.edge.events}get p(){return this.edge.traits}get page(){return this.edge.page}mountWidget(){}}async function Yr(e,t){let i=`/web/projects/${e}`;return t&&(i+=`?profile_id=${t}`),wi(i)}const ts=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function es(e){return typeof e=="string"&&ts.test(e)}function is(e,t="ko"){const i=window[t],n=Array.isArray(i)&&i[0]?[...i]:[];for(const[r,...s]of n)typeof e[r]=="function"&&setTimeout(async()=>{try{await e[r].call(e,...s)}catch(o){console.warn(o)}},0)}function Ie(){}function Pe(){return window.globalKoalaKey||"ko"}async function ns(e,t){var i;try{const n=await Yr(e,t);return n.profile_id?It(n).setId(n.profile_id):t||It(n).id(),n.sdk_settings={...n.sdk_settings||{},...((i=window.koalaSettings)==null?void 0:i.sdk_settings)||{}},{...n,project:e}}catch(n){throw console.warn("[KOALA]","Failed to load project settings",n),n}}async function xe(e){var t;const i=Pe(),n=window[i];if(n&&!Array.isArray(n))return console.warn("[KOALA]","The Koala SDK is already loaded. Calling `load` again will have no effect."),n;const r=(t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.toLowerCase(),s=["googlebot","google web preview","adsbot","headlesschrome","lighthouse","speedindex","vercelbot","hubspot","yandex","ahrefsbot","ev-crawl","facebookexternalhit","facebookcatalog","sightbulb","slackbot","yahoo","bingbot","applebot","discordbot","baidu","screaming","pingdom","phantomjs"];if(navigator!=null&&navigator.webdriver||s.some(l=>r==null?void 0:r.includes(l)))return n;let o=!1;const a=e.profileId;a&&(delete e.profileId,es(a)?It().setId(a):(o=!0,console.warn("[KOALA]","The profileId provided on initialization is invalid. Please provide a valid UUID.")));const c=await ns(e.project,we()),u=new Zr({...e,...c});if(is(u,i),u.emit("initialized",c),u.subscribe(),o){const l=typeof a;u.stats.increment("sdk.error",{method:"load",message:"Invalid profileId provided on initialization",profileId:l==="string"?a:l})}return window[i]=u,window.koala=u,u}typeof W!="undefined"&&typeof window!="undefined"&&typeof window.KoalaSDK=="undefined"&&(window.KoalaSDK={load:xe,mountWidget:Ie})})(),ht})())});as();})(); //# sourceMappingURL=umd.js.map